//
//  CYOrderDetailCell.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/6/27.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYOrderDetailCell.h"
@interface CYOrderDetailCell()
@property (nonatomic, strong) CYLabel *titleLBL;
@property (nonatomic, strong) CYLabel *contentLBL;
@property (nonatomic, strong) CYView *line;
@end

@implementation CYOrderDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.line.hidden = NO;
      self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (CYLabel *)titleLBL{
    if (!_titleLBL) {
        _titleLBL = [[CYLabel alloc]initWithText:[NSString stringWithFormat:@"%@",_titleStr] size:AL(PT(28)) textcolor:ColorHex(0x888888)];
        _titleLBL.justSizeToFit = YES;
        [self addSubview:_titleLBL];
        
        [_titleLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(AL(PT(20)));
            make.centerY.equalTo(self);
            make.size.mas_equalTo(_titleLBL.bounds.size);
        }];
    }
    return _titleLBL;
}

- (CYLabel *)contentLBL{
    if (!_contentLBL) {
        _contentLBL = [[CYLabel alloc]initWithText:_content size:AL(PT(28)) textcolor:(([_titleStr containsString:@"投注号码"])?ColorHex(0xff5b05):ColorHex(0x333333))];
        _contentLBL.justSizeToFit = YES;
        [self addSubview:_contentLBL];
        
        [_contentLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).with.offset(-AL(PT(20)));
            make.centerY.equalTo(self);
            make.size.mas_equalTo(_contentLBL.bounds.size);
        }];
    }
    return _contentLBL;
}

- (CYView *)line{
    if (!_line) {
       _line = [[CYView alloc]initWithColor:ColorHex(0xf5f5f9)];
        [self addSubview:_line];
        
        [_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.mas_bottom).with.offset(0);
            make.centerX.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 0.5));
        }];
    }
    return _line;
}

- (void)setTitleStr:(NSString *)titleStr{
    if (_titleStr != titleStr)
        _titleStr = titleStr;
    self.titleLBL.hidden = NO;
}

- (void)setContent:(NSString *)content{
    if (_content != content)
        _content = [self convertString:content];
    self.contentLBL.text = content;
}

- (NSString *)convertString:(NSString *)string{
   NSString *newStr = [NSString stringWithFormat:@"%@",string];
    if ([_titleStr containsString:@"彩种"] || [_titleStr containsString:@"玩法"])
        return newStr;
    else if ([_titleStr containsString:@"期次"])
        return [NSString getDateNumber:newStr];
    else if ([_titleStr containsString:@"开奖号码"])
        return (newStr.length <= 0)?@"- - - - -":string;
    else if ([_titleStr containsString:@"开奖状态"])
        return ([newStr integerValue] == 2)?@"待开奖":@"已开奖";
    else if ([_titleStr containsString:@"投注号码"])
        return newStr;
    else if ([_titleStr containsString:@"投注注数"])
        return [NSString stringWithFormat:@"%@注", string];
    else if ([_titleStr containsString:@"投注金额"])
        return [NSString stringWithFormat:@"%@元", string];
    else if ([_titleStr containsString:@"投注时间"])
        return newStr;
    return nil;
}
//
//- (NSString *)date:(NSString *)date{
//    NSString *new_date = [NSString stringWithFormat:@"%@-%@-%@", [date substringToIndex:4], [date substringWithRange:NSMakeRange(4, 2)], [date substringWithRange:NSMakeRange(6, 2)]];
//    NSString *new_time = [NSString stringWithFormat:@"%@", [NSString getTime:[[date substringFromIndex:8] integerValue]]];
//    return [NSString stringWithFormat:@"%@ %@", new_date, new_time];
//}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
